//
//  CellOfzhuyi2.m
//  project-A (pianke)
//
//  Created by dllo on 16/3/2.
//  Copyright © 2016年 scott. All rights reserved.
//

#import "CellOfzhuyi2.h"
#import "ModelOfzhuyi.h"
#import <DKNightVersion.h>

#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT self.contentView.bounds.size.height


@interface CellOfzhuyi2 ()<UIScrollViewDelegate>

@end

@implementation CellOfzhuyi2

-(void)dealloc{
   
    [_photos release];
    [_label_des release];
    [_label_title release];
    [_scroll release];
    [super dealloc];
    
}

-(void)passAnyModel:(id)model{
    ModelOfzhuyi *mode = model;
    
    self.label_des.text = mode.descriptions;
    self.label_title.text = mode.title;
    self.photos = mode.photos;
    
//    NSLog(@"去你妹的%@",self.photos);
    
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatview];
        
        self.photos = [NSArray array];
        
    }
    
    return self;
}

-(void)creatview{
    self.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor],  [UIColor colorWithRed:0.16 green:0.14 blue:0.13 alpha:1]);
    
    self.label_des = [[UILabel alloc] init];
    self.label_des.numberOfLines = 0;
    [self.contentView addSubview:self.label_des];
    
     self.label_des.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    [self.label_des release];
    
    self.label_title = [[UILabel alloc] init];
    [self.contentView addSubview:self.label_title];
    
    self.label_title.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    [self.label_title release];
    
    self.scroll = [[UIScrollView alloc]init];
    [self.contentView addSubview:self.scroll];
    
    self.scroll.backgroundColor = [UIColor  whiteColor];
    
    [self.scroll release];
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.scroll.frame = CGRectMake(10, [[self class] heightForLabel:self.label_des.text] + 60, WIDTH - 20, WIDTH * 0.5);
    
   
    
    self.label_title.frame = CGRectMake(10, 10, WIDTH - 20, 30);
    
    self.label_title.font = [UIFont fontWithName:@"Arial-BoldMT" size:20];
    
    self.label_des.frame = CGRectMake(10, 10 + 30 + 10, WIDTH - 20, [[self class] heightForLabel:self.label_des.text]);
    
    
    
}
+ (CGFloat)heightForLabel:(NSString *)text {
    
    CGRect rectview = [text boundingRectWithSize:CGSizeMake(WIDTH - 20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
    
    return rectview.size.height;
    
    
}

- (CGFloat)heightForCell:(ModelOfzhuyi *)model {
    return  [CellOfzhuyi2 heightForLabel:model.descriptions];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
